<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>用户管理</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css">
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <div class="container">
            <a class="navbar-brand" href="/">电影系统</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link" href="/">首页</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/movie/list">电影列表</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link active" href="/user/list">用户管理</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <div class="container mt-4">
        <div class="d-flex justify-content-between align-items-center mb-4">
            <h2>用户管理</h2>
            <a href="/user/add" class="btn btn-primary">添加用户</a>
        </div>

        <table class="table table-striped table-hover">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>用户名</th>
                    <th>昵称</th>
                    <th>手机</th>
                    <th>邮箱</th>
                    <th>注册时间</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                <tr th:each="user : ${users}">
                    <td th:text="${user.id}">1</td>
                    <td th:text="${user.username}">用户名</td>
                    <td th:text="${user.nickname}">昵称</td>
                    <td th:text="${user.phone}">手机号</td>
                    <td th:text="${user.email}">邮箱</td>
                    <td th:text="${#dates.format(user.createTime, 'yyyy-MM-dd HH:mm:ss')}">注册时间</td>
                    <td>
                        <a th:href="@{'/user/detail/' + ${user.id}}" class="btn btn-sm btn-info">查看</a>
                        <a th:href="@{'/user/edit/' + ${user.id}}" class="btn btn-sm btn-primary">编辑</a>
                        <a th:href="@{'/user/delete/' + ${user.id}}" class="btn btn-sm btn-danger" onclick="return confirm('确定要删除这个用户吗？')">删除</a>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
